package org.yaukie.util;

public class CastUtil {
    public CastUtil() {
    }

    public static int castInt(Object obj) {
        return castInt(obj);
    }

    public static int castInt(Object obj, int defaultValue) {
        int intValue = defaultValue;
        if (obj != null) {
            String strValue = castString(obj);
            if (StringUtil.isNotEmpty(strValue)) {
                try {
                    intValue = Integer.parseInt(strValue);
                } catch (NumberFormatException var5) {
                    intValue = defaultValue;
                }
            }
        }

        return intValue;
    }

    public static String castString(Object obj) {
        return castString(obj, "");
    }

    public static String castString(Object obj, String defaultValue) {
        return obj != null ? String.valueOf(obj) : defaultValue;
    }

    public static boolean castBoolean(Object obj) {
        return castBoolean(obj, true);
    }

    public static boolean castBoolean(Object obj, boolean defaultValue) {
        boolean v = defaultValue;
        if (obj != null) {
            v = Boolean.parseBoolean(castString(obj));
        }

        return v;
    }

    public static double castDouble(Object obj) {
        return castDouble(obj, 0.0);
    }

    public static double castDouble(Object obj, double defaultValue) {
        double v = defaultValue;
        if (obj != null) {
            String strValue = castString(obj);
            if (StringUtil.isNotEmpty(strValue)) {
                try {
                    v = Double.parseDouble(strValue);
                } catch (NumberFormatException var7) {
                    v = defaultValue;
                }
            }
        }

        return v;
    }

    public static double castLong(Object obj) {
        return castLong(obj, 0L);
    }

    public static double castLong(Object obj, long defaultValue) {
        long v = defaultValue;
        if (obj != null) {
            String strValue = castString(obj);
            if (StringUtil.isNotEmpty(strValue)) {
                try {
                    v = Long.parseLong(strValue);
                } catch (NumberFormatException var7) {
                    v = defaultValue;
                }
            }
        }

        return (double)v;
    }

    public static void main(String[] args) {
        System.out.println("dds");
    }
}
